home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Modules / BackSpaceModules / Source / Scaled / ScaledViewPart.m < prev    next >
Text File  |  1994-05-04  |  2KB  |  109 lines

  1. #import "ScaledViewPart.h"
  2. #import "Thinker.h"
  3. #import <appkit/NXImage.h>
  4. #import <appkit/Window.h>
  5. #import <appkit/Panel.h>                // for NXRunAlertPanel()
  6. #import <dpsclient/wraps.h>
  7. #import <libc.h>
  8. #import <math.h>
  9.  
  10. @implementation ScaledView
  11.  
  12. - oneStep
  13. {
  14.   float mx, my;
  15.   float xi, yi;
  16.   
  17.   pp=p; p=n;
  18.   n=(n+1)%(NUMLINES-1);
  19.  
  20.   PScurrentmouse(winNum, &mx, &my);
  21.   xi=((mx-midx)/urx)*10.0;
  22.   yi=((my-midy)/ury)*10.0;
  23.  
  24.   if((count++>500) && (((mx != oldx) && (my != oldy)) || (count>30000))){
  25.     count=0;
  26.     PSsetgray(0.0);
  27.     NXRectFill(&bounds);
  28.   }
  29.   oldx=mx; oldy=my;
  30.  
  31.  
  32.   t1[n]=t1[p]+0.2*xi; if(t1[n]>(2*PI)) t1[n]-=(2*PI);
  33.   t2[n]=t2[p]+0.2*yi; if(t2[n]>(2*PI)) t2[n]-=(2*PI);
  34.   t3[n]=t3[p]+0.01;   if(t3[n]>(2*PI)) t3[n]-=(2*PI);
  35.  
  36.   x1[n]=(cos(t1[n])*s1) + (cos(t2[n])*s3) + midx;
  37.   yc1[n]=(sin(t1[n])*s2) + (sin(t2[n])*s4) + midy;
  38.  
  39.   PSsetrgbcolor((cos(t1[n])+1.0)/2.0,
  40.                 (cos(t2[n])+1.0)/2.0,
  41.                 (cos(t3[n])+1.0)/2.0);
  42.  
  43.   PSnewpath();
  44.   PSmoveto(x1[pp], yc1[pp]);
  45.   PSlineto(x1[p], yc1[p]);
  46.   PSlineto(x1[n], yc1[n]);
  47.   PSclosepath();
  48.   PSfill();
  49.  
  50.   return self;
  51. }
  52.  
  53. - initFrame:(NXRect *)frameRect
  54. {
  55.   [super initFrame:frameRect];
  56.   [self newSize];
  57.   winNum=[[self window] windowNum];
  58.   return self;
  59. }
  60.  
  61. - sizeTo:(NXCoord)width :(NXCoord)height
  62. {
  63.   [super sizeTo:width :height];
  64.   [self newSize];
  65.   return self;
  66. }
  67.  
  68. - newSize
  69. {
  70.   int jkl;
  71.   urx=bounds.size.width;
  72.   ury=bounds.size.height;
  73.   
  74.   midx=urx/2;
  75.   midy=ury/2;
  76.  
  77.   n = 0;
  78.   t = 0;
  79.   
  80.   // phases of the three points;
  81.   p1=0;
  82.   p2=(4*PI)/3;
  83.   p3=(2*PI)/3;
  84.   
  85.   // starting angle of each point;
  86.   t1[0]=0;
  87.   t2[0]=p2;
  88.   t3[0]=p3;
  89.  
  90.   for(jkl=0;jkl<NUMLINES;jkl++){
  91.     x1[jkl]=midx;
  92.     yc1[jkl]=midy;
  93.   }
  94.  
  95.   // s1 and s2 should define an oval that takes up middle 75% of the screen
  96.   s1 = midx*0.5; s2 = midy*0.5;
  97.   s3 = midx*0.5; s4 = midy*0.5;
  98.  
  99.   // line per is the percentage back that erase steps
  100.   lper=NUMLINES-5;
  101.  
  102.   n=lper;
  103.   p=(lper/3)*2;
  104.   pp=(lper/3);
  105.   return self;
  106. }
  107.  
  108. @end
  109.